package kyluzoi.test;

import android.graphics.Color;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;

import java.text.ParseException;

import butterknife.Bind;
import butterknife.ButterKnife;

import static android.R.attr.path;

public class MainActivity extends AppCompatActivity {

    @Bind(R.id.testView)
    PathBaseView mTestView;
    @Bind(R.id.activity_main)
    RelativeLayout mActivityMain;

    String pathString = "M895.1,434.1l-227,-0.3L536.1,144.3c-14.9,-25.4 -28.5,-52.4 -78.7,-52.4 -25.5,0 -78.7,0.1 -78.8,78.8l26.2,262.8 -187.8,-0.2 -65.8,-109.7c-9.6,-16.4 -21,-22.5 -35.1,-21.8 -7.6,0.8 -50.1,-5.5 -50.1,28.6l22.7,181.4L66,693.2c-0,24.7 19.1,28.4 49.7,29.2 19.9,-0 22.9,-7.3 34.3,-24.8l67.3,-106.9 187.1,-0.3 -26.4,262.6c-0.1,78.7 53.1,78.7 78.7,78.7 50.1,-0.1 63.8,-27.2 78.8,-52.6l133,-289.2 226.7,-0.4c44.7,-0.1 88.8,-32.8 88.9,-77.2C984.1,467.8 939.8,434 895.1,434.1zM900.3,547.8l-266,0.5L493.7,849.4c-8.7,16.6 -26.8,29.8 -37.1,29.8 -29.1,0 -32.5,-17.3 -31.9,-28.8l45.1,-301.8 -284.7,0.5 -69.4,120.5c0,-20.2 20,-158.1 20,-160.9 0,-1.9 -19.7,-137.2 -19.7,-154l66.5,115.6 287,2.6 -44.8,-299.6c-0.5,-9.4 6,-28.9 32.7,-28.9 10.2,-0 27.3,13.9 35.9,30.5l140.2,299.6 266.7,2.4c18.8,-0 36.3,19.4 36.2,35.9C936.5,529.2 919.1,547.7 900.3,547.8z";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        SvgPathParser svgPathParser = new SvgPathParser();
        try {
            Path path = svgPathParser.parsePath(pathString);
//            Log.d("MainActivity", "pathMeasure.getLength():" + pathMeasure.getLength());
            //path 转换没问题
            Path sPath = new Path();
            sPath.moveTo(0, 0);
            sPath.addCircle(50, 50, 60, Path.Direction.CW);
            sPath.addCircle(50, 50, 40, Path.Direction.CW);
            mTestView.setBasePath(sPath);
            //设置颜色
            mTestView.setColorBg(Color.BLUE).setColorFg(Color.RED);
            //当然你可以自己拿到Paint，然后搞事情，我这里设置线条宽度
            mTestView.getPaint().setStrokeWidth(10);
            mTestView.startAnim();
        } catch (ParseException e) {
            Log.d("MainActivity", "失败");
            e.printStackTrace();
        }
    }
}
